const baseUrl = 'http://117.50.178.51:8887/api'; // 你的API域名
 
function request(options) {
  return new Promise((resolve, reject) => {
    const fullUrl = baseUrl+options.url;
    uni.request({
      url: fullUrl,
      method: options.method || 'GET',
      data: options.data || {},
      header: options.header || { 'Content-Type': 'application/json' },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data);
        } else {
          reject(res.data);
        }
      },
      fail: (err) => {
        reject(err);
      }
    });
  });
}
 
export default {
  get(url, data, header) {
    return request({ url, method: 'GET', data, header });
  },
  post(url, data, header) {
    return request({ url, method: 'POST', data, header });
  }
  // 可以根据需要添加更多的方法，例如put, delete
};